<?php
declare (strict_types = 1);

namespace app\controller\admin;

use app\controller\admin\AdminBaseController;
use app\model\admin\SysLoginLog as SysLoginLogModel;

use think\Request;

class SysLoginLog extends AdminBaseController
{
     /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index(Request $request)
    {
        $field = "*";
        $data = SysLoginLogModel::scope('where', $request->param())
            ->field($field)
            ->order('id','desc')
            ->paginate([
                'list_rows' => $this->limit,
                'page' => $this->page,
                'var_page' => $this->pageVar
            ]);
        
        return successPage($data);
    }

    /**
     * 删除指定资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function delete(Request $request)
    {
        $id = $request->param('id', '');
        if(!$id){
            return error('缺少必要参数');
        }
        $ids = explode(',', $id);

        $ret = SysLoginLogModel::destroy($ids);
        if(!$ret){
            return error('删除失败');
        }
        return success();
    }

    public function clean(){
        return error('暂不支持清空');
    }

    
}
